package com.heima.client.article;

import com.heima.model.common.comment.dtos.CommentManagePageDto;
import com.heima.model.common.dtos.ArticleDto;
import com.heima.model.common.dtos.CommentUpdateStatusDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.pojos.article.ApArticleConfig;
import com.heima.model.common.pojos.article.AdArticleStatistics;
import com.heima.model.common.pojos.article.ApArticle;
import com.heima.model.common.pojos.article.ApAuthor;
import com.heima.model.common.pojos.user.ApUserFollow;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.*;
import com.heima.client.article.fallback.ArticleClientFallback;

import java.util.Date;

/**
 * @author 陈辉
 * @data 2024 15:20
 */
@FeignClient(value = "leadnews-article", fallback = ArticleClientFallback.class)
@Primary//作为首选 Bean
public interface IArticleClient {

    /**
     * 保存或修改article文章信息
     *
     * @param articleDto
     * @return
     */
    @PostMapping("/api/v1/article/sync")
    public ResponseResult syncArticle(@RequestBody ArticleDto articleDto);

    /**
     * 获取作者对象
     * @param userId
     * @return
     */
    @GetMapping("/api/v1/author/{userId}")
    ResponseResult getOne(@PathVariable Integer userId);

    /**
     * 更新作者
     * @param author
     * @return
     */
    @PostMapping("/api/v1/author/")
    ResponseResult update(@RequestBody ApAuthor author);

    /**
     * 根据作者ID查询
     * @param entryId
     * @return
     */
    @GetMapping("/api/v1/article/info/{entryId}")
    public ResponseResult getArticleInfo(@PathVariable Long entryId);

    /**
     * 分页查询当前作者的文章数据
     * @param beginDate
     * @param endDate
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/api/v1/article/newsPage/{beginDate}/{endDate}/{page}/{size}/{id}")
    PageResponseResult newsPage(@PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginDate,
                            @PathVariable @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
                            @PathVariable Integer page,
                            @PathVariable Integer size,
                            @PathVariable Integer id);

    /**
     * 根据文章id查询文章配置
     * @param articleId
     * @return
     */
    @GetMapping("/api/v1/article/{articleId}")
    public ApArticleConfig getArticleConfig(@PathVariable("articleId") Long articleId);


    /**
     * 更改文章评论状态
     * @param statusDto
     * @return
     */
    @PostMapping("/api/v1/article/update/comment/status")
    ResponseResult updateArticleCommentStatus(@RequestBody CommentUpdateStatusDto statusDto);

    /**
     * 查询符合条件文章
     * @param commentDto
     */
    @PostMapping("/api/v1/article/findList")
    PageResponseResult findList(@RequestBody CommentManagePageDto commentDto);

    //查询文章信息
    @GetMapping("/api/v1/articleDetail/{id}")
    ApArticle getArticleById(@PathVariable("id") Long id);

    //更新文章信息
    @PutMapping("/api/v1/article")
    void updateArticle(@RequestBody ApArticle article);
}
